package com.gulimall.product.dao;

import com.gulimall.product.entity.SkuSaleAttrValueEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gulimall.product.vo.ItemVo.SkuItemSaleAttrVo;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * sku销售属性&值
 * 
 * @author Rookie-886
 * @email ${email}
 * @date 2021-03-14 16:30:53
 */
@Mapper
public interface SkuSaleAttrValueDao extends BaseMapper<SkuSaleAttrValueEntity> {

    @Select("<script>select id,sku_id,attr_id,attr_name,attr_value,attr_sort from pms_sku_sale_attr_value where sku_id in " +
            "<foreach collection='list' item='i' open='(' close=')' separator=','>#{i}</foreach></script>")
    List<SkuSaleAttrValueEntity> selectListBySkuIdList(List<Long> skuIdList);

    //todo 复杂sql
    List<SkuItemSaleAttrVo> getSkuItemSaleAttrVo(Long spuId);

    @Select("select concat(attr_name,':',attr_value) from pms_sku_sale_attr_value where sku_id=#{skuId}")
    List<String> getAttrValueList(Long skuId);
}
